package com.cqie.tes.controller;


import com.cqie.tes.comm.R;
import com.cqie.tes.domain.Course;
import com.cqie.tes.domain.Dept;
import com.cqie.tes.domain.qo.tes.CourseQo;
import com.cqie.tes.domain.qo.tes.DeptQo;
import com.cqie.tes.service.CourseService;
import com.cqie.tes.service.DeptService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author DD-GKD
 * @since 2020-09-18
 */
@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    @ApiOperation("分页查询列表")
    @PostMapping("/list")
    public R list(DeptQo qo){
        return deptService.getList(qo);
    }

    @ApiOperation("新增班级")
    @PostMapping("/add")
    public R add(
            @ApiParam(name = "entity",value = "角色对象") Dept entity){
        return deptService.edit(entity);
    }

    @ApiOperation("修改班级")
    @PostMapping("/update")
    public R update(Dept entity) {
        return deptService.edit(entity);
    }

    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    public R delete(
            @ApiParam(value = "角色ID") @PathVariable("id") Integer id
    ){
        return deptService.deleteById(id);
    }

    @ApiOperation("根据ID批量删除")
    @GetMapping("/batchDelete/{ids}")
    public R batchDelete(
            @ApiParam(value = "角色ID列表:1,2,3") @PathVariable("ids") String ids
    ){
        return deptService.deleteByIds(ids);
    }

    @PostMapping("/optionlist")
    public R optionList(){
        return deptService.optionList();
    }
}

